﻿using System;
using System.Activities;
using System.Activities.Tracking;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AuditSample
{
    public class SaveHistoryActivity : CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> State { get; set; }
        public InArgument<string> Action { get; set; }
        public InArgument<string> Auditer { get; set; }
        public InArgument<string> Comment { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            // create and set the record data
            CustomTrackingRecord customRecord = new CustomTrackingRecord("HistoryTracking");
            customRecord.Data.Add("State", this.State.Get(context));
            customRecord.Data.Add("Action", this.Action.Get(context));
            customRecord.Data.Add("Auditer", this.Auditer.Get(context));
            customRecord.Data.Add("Comment", this.Comment.Get(context));
            customRecord.Data.Add("Date", DateTime.Now);
            // emit the record
            context.Track(customRecord);
        }
    }
}
